package com.liuqi.openai.keyword;

import java.util.Arrays;

/**
 * 关键词词典
 *
 * @author liuqi
 * @date 2025/8/3
 **/
public class Dictionary {

    /**
     * 词性默认值: 没有词性
     */
    private final static String DEFAULT_POS_TAG = "UNK";

    /**
     * 关键词
     */
    private final String keyword;

    /**
     * 词性
     *
     * 标签	英文全称	        中文解释	    示例
     * N	Noun	        名词	        "苹果"、"算法"
     * V	Verb	        动词	        "运行"、"学习"
     * A	Adjective	    形容词	    "美丽的"、"快速"
     * D	Adverb	        副词	        "非常"、"迅速地"
     * P	Preposition	    介词	        "在"、"关于"
     * C	Conjunction	    连词	        "和"、"但是"
     * M	Numeral	        数词	        "三"、"100"
     * Q	Quantifier	    量词	        "个"、"次"
     * R	Pronoun	        代词	        "我"、"它"
     * U	Auxiliary	    助词	        "的"、"了"
     * W	Punctuation	    标点符号	    "，"、"。"
     */
    private final String posTag;

    /**
     * 相关的关键词
     */
    private final String[] related;

    /**
     * 关键词是否停用
     */
    private final boolean stop;

    public Dictionary(String keyword) {
        this(keyword, null, null, false);
    }

    public Dictionary(String keyword, String posTag) {
        this(keyword, posTag, null, false);
    }

    public Dictionary(String keyword, String posTag, String[] related) {
        this(keyword, posTag, related, false);
    }

    public Dictionary(String keyword, String posTag, String[] related, boolean stop) {
        this.keyword = keyword;
        this.posTag = posTag == null ? DEFAULT_POS_TAG : posTag;
        this.related = related;
        this.stop = stop;
    }

    public String getKeyword() {
        return keyword;
    }

    public String getPosTag() {
        return posTag;
    }

    public String[] getRelated() {
        return related;
    }

    public boolean isStop() {
        return stop;
    }

    @Override
    public String toString() {
        return "Dictionary{" +
                "keyword='" + keyword + '\'' +
                ", posTag='" + posTag + '\'' +
                ", related=" + Arrays.toString(related) +
                ", stop=" + stop +
                '}';
    }
}
